package com.ruoyi.shop.cms.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.shop.cms.domain.ShopMaterial;
import org.springframework.stereotype.Service;
import com.ruoyi.shop.cms.mapper.ShopMaterialMapper;
import com.ruoyi.shop.cms.service.IShopMaterialService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 商城素材实现类
 * 
 * @author ruoyi
 */
@Service
public class ShopMaterialServiceImpl implements IShopMaterialService {
	@Autowired
	private ShopMaterialMapper shopMaterialMapper;

	/**
	 * 查询商城素材
	 * 
	 * @param materialId 商城素材主键
	 * @return 商城素材
	 */
	@Override
	public ShopMaterial selectMaterialById(Long materialId) {
		return shopMaterialMapper.selectMaterialById(materialId);
	}

	/**
	 * 查询商城素材列表
	 * 
	 * @param shopMaterial 商城素材
	 * @return 商城素材
	 */
	@Override
	public List<ShopMaterial> selectMaterialList(ShopMaterial shopMaterial) {
		List<ShopMaterial> list = shopMaterialMapper.selectMaterialList(shopMaterial);
		return list;
	}

	/**
	 * 批量新增商城素材
	 * 
	 * @param shopMaterial 商城素材
	 * @return 结果
	 */
	public int insertMaterials(List<ShopMaterial> shopMaterials) {
		return shopMaterialMapper.insertMaterials(shopMaterials);
	}

	/**
	 * 修改商城素材
	 * 
	 * @param shopMaterial 商城素材
	 * @return 结果
	 */
	@Override
	public int updateMaterial(ShopMaterial shopMaterial) {
		shopMaterial.setUpdateTime(DateUtils.getNowDate());
		return shopMaterialMapper.updateMaterial(shopMaterial);
	}

	/**
	 * 删除商城素材信息
	 * 
	 * @param materialId 商城素材主键
	 * @return 结果
	 */
	@Override
	public int deleteByMaterialId(Long materialId) {
		return shopMaterialMapper.deleteByMaterialId(materialId);
	}

	/**
	 * 批量删除商城素材
	 * 
	 * @param materialIds 需要删除的商城素材主键集合
	 * @return 结果
	 */
	@Override
	public int deleteByMaterialIds(String materialIds) {
		return shopMaterialMapper.deleteByMaterialIds(Convert.toStrArray(materialIds));
	}

	/**
	 * 批量修改素材分组
	 * 
	 * @param materialIds
	 * @param groupId
	 * @return
	 */
	@Override
	public int changeGroup(String materialIds, Long groupId) {
		return shopMaterialMapper.changeGroup(Convert.toStrArray(materialIds), groupId);
	}
}
